package com.cloud.alibaba.common.util;

import java.math.BigDecimal;

/**
 * @author taoxinhuan
 * @description: 金钱转换
 * @date 2020/9/29 16:21
 */
public class MoneyUtil {

    public static final Integer TIMES_100 = 100;

    /**
     * 整形钱转string
     * @param m
     * @return
     */
    public static String getMoney(Integer m){
        if(m==null){
            return "0";
        }
        BigDecimal b=new BigDecimal(m);
        BigDecimal divide = b.divide(new BigDecimal(TIMES_100));
        return divide.toString();
    }
    /**
     * 整形钱转string
     * @param m
     * @return
     */
    public static Integer getOriginMoney(String m){
        if(m==null){
            return 0;
        }
        BigDecimal b=new BigDecimal(m);
        BigDecimal res = b.multiply(new BigDecimal(TIMES_100));
        return res.intValue();
    }
}
